package com.ruipengkj.view.systemView;

import java.awt.Component;
import java.awt.Graphics;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellRenderer;

import com.ruipengkj.commons.util.Util;

public class PrivilegeJTableHeader extends JLabel implements TableCellRenderer {

	private static final long serialVersionUID = 1L;

//	private Image img = ImageFactory.loadImage(ImageFactory.PANEL_DISH_TYPE_BG).getImage();
//	private ImageIcon icon=ImageFactory.loadImage(ImageFactory.ICON_4);
	
	public PrivilegeJTableHeader() {
		Util.setSize(this, 200, 100);
//		this.setIcon(icon);
		setHorizontalAlignment(SwingConstants.CENTER);
//		setHorizontalTextPosition(SwingConstants.RIGHT);
//		setVerticalTextPosition(SwingConstants.CENTER);
		this.setBorder(BorderFactory.createTitledBorder(""));
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
	}
	
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		this.setFont(Util.TABLE_CELL_FONT);
		String Value = value.toString();
		if (column >= 2) {
			String text = "<html>";
			for (int i = 0; i < Value.length(); i++) {
				text += Value.substring(i, i+1);
				text += "<br>";
			}
			text += "</html>";
	        this.setText(text);
		} else {
			this.setText(Value);
		}
        return this;
	}
}
